/*
 * @Author: szx
 * @Date: 2022-03-16 15:57:30
 * @LastEditTime: 2022-03-16 16:00:36
 * @Description:
 * @FilePath: \learn\手撸JS源码\instance.js
 */
function myInstanceOf(left, right) {
    // 如果对象不存在并且不是object实例对象，false
    if (!left || typeof left !== 'object') return false;
    // 获得左边的原型
    let proto = Object.getPrototypeOf(left);
    while (true) {
        if (proto === null) return false;
        if (proto === right.prototype) return true;
        proto = Object.getPrototypeOf(proto);
    }
}
